﻿#region License
// Copyright 2010 Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MediaWiki.MediaWikiConverter.Utilities.Registry;
using NUnit.Framework;
using Microsoft.Win32;
using MediaWiki.MediaWikiConverter.Utilities;

namespace MediaWiki.MediaWikiConverter.Tests.Utilities
{
  public class RegistryExTests : TestsBase
  {
    //private uint CreateKey(RootRegKeys rrk, string path)
    //{
    //  uint nKey = 0;
    //  RegResult nDisposition = 0;
    //  int rez = RegistryEx.RegCreateKeyEx((uint)rrk, path, 0, String.Empty, 0, RegSAM.WOW64_64Key, IntPtr.Zero, out nKey, out nDisposition);
    //  if (rez != 0) throw new Exception("Can't create key");
    //  return nKey; //Key handle
    //}

    //[Test]
    //public void sdfsdf()
    //{
    //  //string l_strExampleKey = "SOFTWARE\\TestKey";

    //  //int key;
    //  //RegistryEx.RegCreateKeyEx(RootRegKeys.HKEY_LOCAL_MACHINE, l_strExampleKey, 0, null, RegOption.NonVolatile,
    //  //                          RegSAM.AllAccess, null, out key, RegResult.CreatedNewKey);

    //  uint key = CreateKey(RootRegKeys.HKEY_LOCAL_MACHINE, "SOFTWARE\\TestKey");

    //  //RegistryEx.RegSetValueEx(key, "Blah", 0, RegistryValueKind.String, "Value!", 

    //  RegistryEx.RegCloseKey(key);
    //}

    //[Test]
    //public void RegistryKeyEx()
    //{
    //  if (RegistryEx.LocalMachine.OpenSubKey("SOFTWARE\\TestKeyEx") != null)
    //    RegistryEx.LocalMachine.DeleteSubKeyTree("SOFTWARE\\TestKeyEx");

    //  RegistryKeyEx key = RegistryEx.LocalMachine.CreateSubKey("SOFTWARE\\TestKeyEx");
    //  key.SetValue("Int", int.MaxValue);
    //  key.SetValue("Long", long.MaxValue);
    //  key.SetValue("String", "String!");
    //  key.SetValue("Bytes", new byte[] { 0, 1, 2, 3, 4 });
    //  key.SetValue("MultiString", new string[] { "0", "One", "II" });
    //  //key.SetValue("LongArray", new long[] { 0, 1, 2 });
    //  key.Flush();
    //  key.Close();

    //  if (Registry.LocalMachine.OpenSubKey("SOFTWARE\\TestKeyBuiltin") != null)
    //    Registry.LocalMachine.DeleteSubKeyTree("SOFTWARE\\TestKeyBuiltin");

    //  RegistryKey key2 = Registry.LocalMachine.CreateSubKey("SOFTWARE\\TestKeyBuiltin");
    //  key2.SetValue("Int", int.MaxValue);
    //  key2.SetValue("Long", long.MaxValue);
    //  key2.SetValue("String", "String!");
    //  key2.SetValue("Bytes", new byte[] { 0, 1, 2, 3, 4 });
    //  key2.SetValue("MultiString", new string[] { "0", "One", "II" });
    //  //key2.SetValue("LongArray", new long[] { 0, 1, 2 });
    //  key2.Flush();
    //  key2.Close();

    //  if (Registry.LocalMachine.OpenSubKey("SOFTWARE\\TestKeyBuiltinExplicitString") != null)
    //    Registry.LocalMachine.DeleteSubKeyTree("SOFTWARE\\TestKeyBuiltinExplicitString");

    //  RegistryKey key3 = Registry.LocalMachine.CreateSubKey("SOFTWARE\\TestKeyBuiltinExplicitString");
    //  key3.SetValue("Int", int.MaxValue, RegistryValueKind.String);
    //  key3.SetValue("Long", long.MaxValue, RegistryValueKind.String);
    //  key3.SetValue("String", "String!", RegistryValueKind.String);
    //  key3.SetValue("Bytes", new byte[] { 0, 1, 2, 3, 4 }, RegistryValueKind.String);
    //  key3.SetValue("MultiString", new string[] { "0", "One", "II" }, RegistryValueKind.String);
    //  key3.Flush();
    //  key3.Close();

    //  if (Registry.LocalMachine.OpenSubKey("SOFTWARE\\TestKeyBuiltinExplicitInt") != null)
    //    Registry.LocalMachine.DeleteSubKeyTree("SOFTWARE\\TestKeyBuiltinExplicitInt");

    //  RegistryKey key4 = Registry.LocalMachine.CreateSubKey("SOFTWARE\\TestKeyBuiltinExplicitInt");
    //  key4.SetValue("Int", int.MaxValue, RegistryValueKind.DWord);
    //  //key4.SetValue("Long", long.MaxValue, RegistryValueKind.DWord);
    //  //key4.SetValue("String", "String!", RegistryValueKind.DWord);
    //  //key4.SetValue("Bytes", new byte[] { 0, 1, 2, 3, 4 }, RegistryValueKind.DWord);
    //  //key4.SetValue("MultiString", new string[] { "0", "One", "II" }, RegistryValueKind.DWord);
    //  key4.Flush();
    //  key4.Close();

    //  if (Registry.LocalMachine.OpenSubKey("SOFTWARE\\TestKeyBuiltinBadType") != null)
    //    Registry.LocalMachine.DeleteSubKeyTree("SOFTWARE\\TestKeyBuiltinBadType");

    //  RegistryKey key5 = Registry.LocalMachine.CreateSubKey("SOFTWARE\\TestKeyBuiltinBadType");
    //  key5.SetValue("MultiString", new Version(), RegistryValueKind.MultiString);
    //  //key4.SetValue("Long", long.MaxValue, RegistryValueKind.DWord);
    //  //key4.SetValue("String", "String!", RegistryValueKind.DWord);
    //  //key4.SetValue("Bytes", new byte[] { 0, 1, 2, 3, 4 }, RegistryValueKind.DWord);
    //  //key4.SetValue("MultiString", new string[] { "0", "One", "II" }, RegistryValueKind.DWord);
    //  key5.Flush();
    //  key5.Close();

    //  //if (Windows.Is64Bit())
    //  //{
    //  //  RegistryKeyEx key2 = RegistryEx.LocalMachine.CreateSubKey("SOFTWARE\\TestKey2", true);
    //  //  key2.Close();
    //  //}
    //}
  }
}